<template>
	<view class="container">
		<nav-bar :title="$t('充值記錄')" leftIcon="left"></nav-bar>
		<view class="listMain" v-for="(item,i) in list" :key="i">
			<view class="leftList">
				<view class="text">
					{{item.note}}
				</view>
				<view class="time">
					{{$t('時間')}}：{{item.createTimeStr}}
				</view>
			</view>
			<view class="text">
				+{{item.amountFlow}}
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from "vue";
	import getInviteFriends from '@/hooks/inviteFriends.js'
	import i18n from '@/locale/index'
	const {
		getRechargeRecord
	} = getInviteFriends()
	import {
		onReachBottom
	} from '@dcloudio/uni-app'

	const page = ref({
		pageNum: 1,
		pageSize: 11
	})

	//列表字段
	const list = ref([])

	async function getRechargeRecordList() {
		const res = await getRechargeRecord('order/queryUserIdAroundFlow', {
			userId: uni.getStorageSync('setUserInfo').userId,
			pageNum: page.value.pageNum,
			pageSize: page.value.pageSize
		})
		if (!res.records.length) {
			return uni.showToast({
				title: `${i18n.global.t('没有更多了')}!`,
				icon: 'none',
			})
		}
		list.value = [...list.value, ...res.records]
	}
	getRechargeRecordList()

	//上拉加载更多
	onReachBottom(() => {
		page.value.pageNum++
		getRechargeRecordList()
	})
</script>

<style lang="scss" scoped>
	.listMain {
		padding: 25rpx 45rpx;
		background: #24232C;
		border-radius: 20rpx;
		display: flex;
		align-items: flex-start;
		justify-content: space-between;

		.time {
			color: #808492;
			font-size: 24rpx;
			margin-top: 22rpx;
		}

		.text {
			color: #FFFFFF;
			font-size: 28rpx;
		}

	}
</style>